<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function f1() {
            console.log(this==window)//true
            var sum = 0;
            var obj = {
                inc: function () {
                    sum++;
                    console.log(this==result)//true
                    return sum;
                }
            };
            return obj;
        }
        let result = f1();
        console.log(result.inc());//1
        console.log(result.inc());//2
        console.log(result.inc());//3
    </script>



<script>
    function f2(fn){
        let a=3
        fn()
    }
    let a=1
    function b(){
        console.log('函数作为参数',a)
    }
    f2(b)
</script>
</body>

</html>